<?php

namespace app\common\model;

use app\common\library\Auth;
use think\Model;


class File extends Model
{

    

    

    // 表名
    protected $name = 'file';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'is_charge_text',
        'createtime_text'

    ];

    
    public function getIsChargeList()
    {
        return ['0' => __('Is_charge 0'), '1' => __('Is_charge 1')];
    }


    public function getIsChargeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_charge']) ? $data['is_charge'] : '');
        $list = $this->getIsChargeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getFileAttr($value,$data){
        return $value ? cdnurl($value,true) : '';
    }
    public function getImageAttr($value,$data){
        return $value ? cdnurl($value,true) : '';
    }
    public function getCreateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['createtime']) ? $data['createtime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }



}
